<?php

namespace plugin\sqmadmin\utils;

use Godruoyi\Snowflake\Snowflake as BaseSnowflake;

class Snowflake
{
    protected static $instance;
    
    public static function getInstance()
    {
        if (!self::$instance) {
            $snowflake = new BaseSnowflake();
            
            // 设置起始时间戳（毫秒）
            $startTime = (int)($_ENV['SNOWFLAKE_START_TIME'] ?? 1640995200000);
            $snowflake->setStartTimeStamp($startTime);
            
            self::$instance = $snowflake;
        }
        
        return self::$instance;
    }
    
    public static function id()
    {
        return self::getInstance()->id();
    }
    
    public static function parseId($id)
    {
        return self::getInstance()->parseId($id);
    }
}